package com.bw.controller;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.bw.service.WeekService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
public class WekController {
    @Autowired
    WeekService weekService;

    @RequestMapping("/findshengf")
    public Object findshengf(){
        List<Map> list = weekService.findshengf();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",0);
        jsonObject.put("msg","");
        JSONObject dataObject = new JSONObject();
        JSONArray mapArray = new JSONArray();
        for (Map map : list) {
            JSONObject mapObject = new JSONObject();
            mapObject.put("name",map.get("name"));
            mapObject.put("value",map.get("cc"));
            mapArray.add(mapObject);
        }
        dataObject.put("mapData",mapArray);
        jsonObject.put("data",dataObject);
        return jsonObject;
    }


    @RequestMapping("/findbt")
    public Object findbt(){
        List<Map> list = weekService.findbt();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",0);
        jsonObject.put("msg","");
        JSONArray dataArray = new JSONArray();
        for (Map map : list) {
            JSONObject dataObject = new JSONObject();
            dataObject.put("name",map.get("name"));
            dataObject.put("value",map.get("c"));
            dataArray.add(dataObject);
        }
        jsonObject.put("data",dataArray);
        return jsonObject;
    }
    @RequestMapping("/findfpq")
    public Object findfpq(){
        List<Map> list = weekService.findfpq();
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("status",0);
        jsonObject.put("msg","");
        jsonObject.put("data",list.get(0).get("aa"));
        return jsonObject;
    }
}
